package com.wuhuahe.luanfeng.netty.example.rpc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.Date;

/**
 * Created By wuhuahe
 * author:游龙
 * Date: 2018-07-14
 * Time: 17:05
 * Desc:
 */
public class RpcTest {
    private static final Logger LOGGER = LoggerFactory.getLogger(RpcTest.class);

    public static void main(String[] args) throws InterruptedException {

        //
        ApplicationContext ctx = new ClassPathXmlApplicationContext();

        //
        DemoService demoService = RpcProxy.get(DemoService.class);

        for (int i = 0; i < 100; i++) {

            String result = demoService.hello("luangeng" + i);
            LOGGER.info("result: " + result);

            result = demoService.hello("你好，", "luangeng" + i);
            LOGGER.info("result: " + result);

            Pojo p = new Pojo();
            p.setId(i);
            p.setName("luanegng" + i);
            p.setMan(true);
            p.setBirth(new Date());
            p.setList(new ArrayList<>());
            p.getList().add("pojo" + i);
            Pojo p2 = demoService.test(p);
            LOGGER.info(p2.toString());
            LOGGER.info(" ");
        }

    }
}
